<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Maven 插件开发指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            position: relative;
            overflow: hidden;
        }
        
        .hero-gradient::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            padding: 20px;
            overflow-x: auto;
            position: relative;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
        }
        
        .code-block::before {
            content: attr(data-lang);
            position: absolute;
            top: 8px;
            right: 12px;
            font-size: 12px;
            color: #888;
            text-transform: uppercase;
        }
        
        .feature-card {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            border-radius: 12px;
            padding: 24px;
            transition: all 0.3s ease;
        }
        
        .feature-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
        }
        
        .highlight-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 600;
        }
        
        .step-number {
            width: 32px;
            height: 32px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            flex-shrink: 0;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-family: 'Noto Serif SC', serif;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6 relative">
        <div class="max-w-6xl mx-auto relative z-10">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 tracking-tight">
                    <i class="fas fa-plug mr-4"></i>Maven 插件开发指南
                </h1>
                <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto leading-relaxed">
                    掌握 Maven 插件开发，解锁构建自动化的无限可能
                </p>
                <div class="mt-10 flex justify-center space-x-6">
                    <div class="text-center">
                        <i class="fas fa-cogs text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">自定义构建</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-robot text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">任务自动化</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-puzzle-piece text-4xl mb-2"></i>
                        <p class="text-sm opacity-80">功能扩展</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction -->
        <div class="content-card rounded-xl p-8 mb-8">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">M</span>aven 作为 Java 生态中最流行的构建工具之一，其强大的插件机制为开发者提供了极大的灵活性。通过 Maven 插件，我们可以自定义构建逻辑、自动化重复任务，甚至扩展 Maven 的核心功能。
            </p>
        </div>

        <!-- Section 1: Why Custom Plugins -->
        <div class="content-card rounded-xl p-8 mb-8">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-question-circle mr-3 text-purple-600"></i>为什么需要自定义 Maven 插件？
            </h2>
            <p class="text-gray-700 mb-6 leading-relaxed">
                Maven 提供了丰富的官方插件（如 <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">maven-compiler-plugin</code>、<code class="bg-gray-100 px-2 py-1 rounded text-purple-600">maven-surefire-plugin</code> 等），可以满足大多数项目的构建需求。然而，在实际项目中，我们经常会遇到一些特殊需求：
            </p>
            
            <div class="grid md:grid-cols-3 gap-6">
                <div class="feature-card">
                    <i class="fas fa-code text-3xl text-purple-600 mb-4"></i>
                    <h3 class="font-bold text-lg mb-2">自定义构建逻辑</h3>
                    <p class="text-gray-600">项目可能需要执行一些特定的任务，如生成代码、打包特定资源、调用外部工具等。</p>
                </div>
                <div class="feature-card">
                    <i class="fas fa-sync-alt text-3xl text-purple-600 mb-4"></i>
                    <h3 class="font-bold text-lg mb-2">自动化重复任务</h3>
                    <p class="text-gray-600">某些任务在每次构建时都需要手动执行，例如清理临时文件、生成文档、部署到特定环境等。</p>
                </div>
                <div class="feature-card">
                    <i class="fas fa-expand-arrows-alt text-3xl text-purple-600 mb-4"></i>
                    <h3 class="font-bold text-lg mb-2">扩展 Maven 功能</h3>
                    <p class="text-gray-600">某些项目可能需要扩展 Maven 的核心功能，例如自定义依赖解析逻辑、修改构建生命周期等。</p>
                </div>
            </div>
            
            <p class="text-gray-700 mt-6 bg-purple-50 p-4 rounded-lg border-l-4 border-purple-600">
                <i class="fas fa-lightbulb mr-2 text-purple-600"></i>
                在这些场景下，开发自定义 Maven 插件是最佳选择。通过插件，我们可以将复杂的逻辑封装起来，并通过简单的命令或配置触发执行。
            </p>
        </div>

        <!-- Plugin Architecture Visualization -->
        <div class="content-card rounded-xl p-8 mb-8">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-sitemap mr-3 text-purple-600"></i>Maven 插件架构概览
            </h2>
            <div class="mermaid">
                graph TB
                    A[Maven 项目] -->|引入| B[自定义插件]
                    B --> C[Mojo 接口]
                    C --> D[AbstractMojo]
                    D --> E[CustomMojo 实现]
                    E --> F[execute 方法]
                    B --> G[plugin.xml]
                    G --> H[目标定义]
                    G --> I[参数配置]
                    
                    style A fill:#f9f,stroke:#333,stroke-width:2px
                    style B fill:#bbf,stroke:#333,stroke-width:2px
                    style C fill:#bfb,stroke:#333,stroke-width:2px
                    style F fill:#fbb,stroke:#333,stroke-width:2px
            </div>
        </div>

        <!-- Section 2: Basic Structure -->
        <div class="content-card rounded-xl p-8 mb-8">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-layer-group mr-3 text-purple-600"></i>Maven 插件的基本结构
            </h2>
            
            <p class="text-gray-700 mb-6 leading-relaxed">
                一个 Maven 插件本质上是一个 Maven 项目，其核心是一个实现了 <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">Mojo</code>（Maven Plain Old Java Object）接口的 Java 类。<code class="bg-gray-100 px-2 py-1 rounded text-purple-600">Mojo</code> 是 Maven 插件的最小执行单元，每个 <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">Mojo</code> 对应一个具体的任务。
            </p>

            <h3 class="text-2xl font-bold mb-4 text-gray-700">
                <i class="fas fa-folder-tree mr-2 text-purple-500"></i>插件项目的结构
            </h3>
            
            <div class="code-block mb-6" data-lang="structure">
ts-maven-plugin
├── src
│   ├── main
│   │   ├── java
│   │   │   └── com
│   │   │       └── ts
│   │   │           └── plugin
│   │   │               └── CustomMojo.java
│   │   └── resources
│   │       └── META-INF
│   │           └── maven
│   │               └── plugin.xml
│   └── test
│       └── java
└── pom.xml
            </div>

            <div class="grid md:grid-cols-3 gap-4 mb-6">
                <div class="bg-gray-50 p-4 rounded-lg">
                    <i class="fas fa-file-code text-purple-600 mr-2"></i>
                    <strong>pom.xml</strong>
                    <p class="text-sm text-gray-600 mt-1">定义插件的元信息和依赖</p>
                </div>
                <div class="bg-gray-50 p-4 rounded-lg">
                    <i class="fas fa-coffee text-purple-600 mr-2"></i>
                    <strong>CustomMojo.java</strong>
                    <p class="text-sm text-gray-600 